/**
 * 从左下到右上的方案总数。有障碍。
 */
#include <bits/stdc++.h>
using namespace std;

int getInt(){
    char ch;
    while(not isdigit(ch = getchar()));
    
    int ret = ch ^ '0';
    while(isdigit(ch = getchar())) ret = ret * 10 + (ch ^ '0');
    return ret;
}

int const MOD = 2333;
int M, N;
vector<vector<int>> A;
vector<vector<int>> D;
int main(){
    M = getInt();
    N = getInt();
    A.assign(M, vector<int>(N, 0));
    for(auto & v : A)for(auto & i : v) i = getInt();
    
    D.assign(M, vector<int>(N, 0));
    D[M - 1][0] = 1;
    for(int i=M-1;i>=0;--i)for(int j=0;j<N;++j){
        if(1 == A[i][j]) continue;
        
        if(i < M - 1){
            (D[i][j] += D[i + 1][j]) %= MOD;
        }
        
        if(j > 0){
            (D[i][j] += D[i][j - 1]) %= MOD;
        }
    } 
    cout << D[0][N - 1] << endl;
    return 0;
}